﻿using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web.Mvc;
using Alma.Models;
using AlmaDatabase;

namespace Alma.Controllers
{
    public class CategoriesMenuController : Controller
    {
        [ChildActionOnly]
        public ActionResult Show()
        {
            using (var context = new AlmaDBEntities())
            {
                var model = new CmShowModel();
                model.Groups = new List<CmGroup>();
                foreach (var r in context.Realms)
                {
                    var group = new CmGroup();
                    group.Color = Color.FromArgb(r.Color ?? 0);
                    group.Categories = new List<CmCategory>();
                    foreach (var c in r.Categories)
                    {
                        group.Categories.Add(new CmCategory() { Name = c.Name, ID = c.ID });
                    }

                    model.Groups.Add(group);
                }
                
                return PartialView(model);
            }
        }

    }
}
